package y24.m1.homework;

public class Test7 {
    public static void main(String[] args) {
        int products = 100;
        int defective = 4;
        double goodProb = 0.99;
        double defectiveProb = 0.95;
        double acceptanceProbability = 1.0;
        // 至少一件产品被断定为次品的概率
        double oneDefective = 1 - noDefectiveCase(defective, products);
        // 该批产品能被接收的概率
        double accept = 1 - oneDefective;
        System.out.println("该批产品能被接收的概率：" + accept);
    }
    // 不存在至少一件产品被断定为次品的概率
    private static double noDefectiveCase(int defective, int products) {
        double defectiveProb = (double) defective / products;
        double noDefectiveProb = 1;
        for (int i = 0; i < 3; i++) {
            noDefectiveProb *= (1 - defectiveProb);
        }
        return noDefectiveProb;
    }
}